package com.dyz.wsw.security.config;

import com.dyz.wsw.security.repository.WswSecurityCacheRepository;
import com.dyz.wsw.security.repository.impl.WswSecurityCacheRepositoryImpl;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.data.redis.core.ReactiveRedisTemplate;

/**
 * @author dyz
 * @date 2025/2/15 19:17
 */
@Configuration
@EnableConfigurationProperties(WswSecurityJWTProperties.class)
@Import({RedisConfig.class})
public class WswSecurityAutoConfiguration {

    private final WswSecurityJWTProperties properties;

    private final ReactiveRedisTemplate<String,Object> template;

    public WswSecurityAutoConfiguration(
            WswSecurityJWTProperties properties,
            ReactiveRedisTemplate<String,Object> template
    ){
        this.properties = properties;
        this.template = template;
    }


    @Bean
    public WswSecurityCacheRepository wswSecurityCacheRepository(){
        return new WswSecurityCacheRepositoryImpl(properties, template);
    }

}
